package cn.train.controler;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.train.model.UserTable;
import cn.train.service.UserTableService;

@WebServlet("/FindPassServlet")
public class FindPassServlet extends HttpServlet {

	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String mibao=req.getParameter("mibao");
		String uname = req.getParameter("zh");
		String upass = req.getParameter("pass");

		UserTableService userService=new UserTableService();
		boolean flag = userService.findPass(uname, mibao, upass);
		resp.setContentType("text/html;charSet=utf-8");
		PrintWriter out =resp.getWriter();
		if (flag) {
			out.print("<script>alert('找回密码成功！');location.href='font/login.jsp'</script>");
		} else {
			out.print("<script>alert('账号错误或密保问题错误！');location.href='font/login.jsp'</script>");
	
		}
		
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req,resp);
	}
}
